package com.ruoyi.web.controller.miniprogram;

import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 运输者控制器
 * 处理小程序运输者相关API请求
 *
 * @author ruoyi
 */
@Api("运输者管理")
@RestController
@RequestMapping("/transporter")
@CrossOrigin(origins = "*") // 允许跨域请求
public class TransporterController extends BaseController
{
    
    /**
     * 运输者注册
     */
    @ApiOperation("运输者注册")
    @Log(title = "运输者注册", businessType = BusinessType.INSERT)
    @PostMapping("/register")
    public AjaxResult register(@RequestBody TransporterRegisterRequest request)
    {
        // TODO: 实现运输者注册逻辑
        return AjaxResult.success("注册成功");
    }
    
    /**
     * 运输者登录
     */
    @ApiOperation("运输者登录")
    @Log(title = "运输者登录", businessType = BusinessType.OTHER)
    @PostMapping("/login")
    public AjaxResult login(@RequestBody TransporterLoginRequest request)
    {
        // TODO: 实现运输者登录逻辑
        return AjaxResult.success("登录成功");
    }
    
    /**
     * 修改昵称
     */
    @ApiOperation("修改昵称")
    @Log(title = "修改昵称", businessType = BusinessType.UPDATE)
    @PostMapping("/updateName")
    public AjaxResult updateName(@RequestBody TransporterUpdateNameRequest request)
    {
        // TODO: 实现修改昵称逻辑
        return AjaxResult.success("修改成功");
    }
    
    /**
     * 修改地址
     */
    @ApiOperation("修改地址")
    @Log(title = "修改地址", businessType = BusinessType.UPDATE)
    @PostMapping("/updateLocation")
    public AjaxResult updateLocation(@RequestBody TransporterUpdateLocationRequest request)
    {
        // TODO: 实现修改地址逻辑
        return AjaxResult.success("修改成功");
    }
    
    /**
     * 修改电话
     */
    @ApiOperation("修改电话")
    @Log(title = "修改电话", businessType = BusinessType.UPDATE)
    @PostMapping("/updateTel")
    public AjaxResult updateTel(@RequestBody TransporterUpdateTelRequest request)
    {
        // TODO: 实现修改电话逻辑
        return AjaxResult.success("修改成功");
    }
    
    /**
     * 修改密码
     */
    @ApiOperation("修改密码")
    @Log(title = "修改密码", businessType = BusinessType.UPDATE)
    @PostMapping("/updatePassword")
    public AjaxResult updatePassword(@RequestBody TransporterUpdatePasswordRequest request)
    {
        // TODO: 实现修改密码逻辑
        return AjaxResult.success("修改成功");
    }
}

// 请求实体类
class TransporterRegisterRequest {
    private String username;
    private String password;
    private String nickname;
    private String tel;
    private String location;
    
    // getters and setters
    public String getUsername() { return username; }
    public void setUsername(String username) { this.username = username; }
    public String getPassword() { return password; }
    public void setPassword(String password) { this.password = password; }
    public String getNickname() { return nickname; }
    public void setNickname(String nickname) { this.nickname = nickname; }
    public String getTel() { return tel; }
    public void setTel(String tel) { this.tel = tel; }
    public String getLocation() { return location; }
    public void setLocation(String location) { this.location = location; }
}

class TransporterLoginRequest {
    private String username;
    private String password;
    
    // getters and setters
    public String getUsername() { return username; }
    public void setUsername(String username) { this.username = username; }
    public String getPassword() { return password; }
    public void setPassword(String password) { this.password = password; }
}

class TransporterUpdateNameRequest {
    private String transporterId;
    private String nickname;
    
    // getters and setters
    public String getTransporterId() { return transporterId; }
    public void setTransporterId(String transporterId) { this.transporterId = transporterId; }
    public String getNickname() { return nickname; }
    public void setNickname(String nickname) { this.nickname = nickname; }
}

class TransporterUpdateLocationRequest {
    private String transporterId;
    private String location;
    
    // getters and setters
    public String getTransporterId() { return transporterId; }
    public void setTransporterId(String transporterId) { this.transporterId = transporterId; }
    public String getLocation() { return location; }
    public void setLocation(String location) { this.location = location; }
}

class TransporterUpdateTelRequest {
    private String transporterId;
    private String tel;
    
    // getters and setters
    public String getTransporterId() { return transporterId; }
    public void setTransporterId(String transporterId) { this.transporterId = transporterId; }
    public String getTel() { return tel; }
    public void setTel(String tel) { this.tel = tel; }
}

class TransporterUpdatePasswordRequest {
    private String transporterId;
    private String oldPassword;
    private String newPassword;
    
    // getters and setters
    public String getTransporterId() { return transporterId; }
    public void setTransporterId(String transporterId) { this.transporterId = transporterId; }
    public String getOldPassword() { return oldPassword; }
    public void setOldPassword(String oldPassword) { this.oldPassword = oldPassword; }
    public String getNewPassword() { return newPassword; }
    public void setNewPassword(String newPassword) { this.newPassword = newPassword; }
} 